class UploadFile < ActiveRecord::Base
  def self.save(upload)
    name = upload['datafile'].original_filename
    directory = "public\images\events"
    #tao duong dan luu
    path=File.join(directory,name)
    #ghi file
    File.open(path,"wb") {|f| f.write(upload['datafile'].read) }   
  end
  def self.getpath(upload)
    name = upload['datafile'].original_filename
    directory = "images/"
    #tao duong dan luu
    path=File.join(directory,name)
    return name
  end
end
